@extends('layouts.default')
@section('content')
    <div class="row row-margin-top">
        <div class="col-xs-12">
            <form class="form-inline" action="{{ route('users.index') }}" method="get">
                {{ csrf_field() }}
                <div class="form-group">
                    <input type="text" class="form-control" name="key" placeholder="请输入关键字搜索">
                </div>
                <button type="submit" class="btn btn-info btn-search">查找</button>
                <a href="{{route('users.create')}}" class="btn btn-info btn-search">添加</a>
            </form>
        </div>
    </div>
    <div class="row row-margin-top">
        <div class="col-xs-12">
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <thead>
                    <tr>
                        <th></th>
                        <th>用户名</th>
                        <th>邮箱</th>
                        <th>创建时间</th>
                        <th>最近登陆时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach ($users as $user)
                        <tr>
                            <td>{{$user->id}}</td>
                            <td>{{ $user->name }}</td>
                            <td>{{ $user->email }}</td>
                            <td>{{ $user->created_at }}</td>
                            <td>{{ $user->updated_at }}</td>
                            <td>
                                <a class="pull-left" href="{{route('users.editrole',['id'=>$user->id])}}">
                                    <button type="button" class="btn btn-primary">分配角色</button>
                                </a>

                                <a class="pull-left" style="padding-left: 10px;" href="{{route('users.edit',['id'=>$user->id])}}">
                                    <button type="button" class="btn btn-warning">修改</button>
                                </a>
                                <a class="pull-left" style="padding-left: 10px;">
                                    <form action="{{ route('users.destroy', $user->id) }}" method="post">
                                        {{ csrf_field() }}
                                        {{ method_field('DELETE') }}
                                        <button type="submit" class="btn  btn-danger">删除</button>
                                    </form>
                                </a>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="row row-margin-top">
        <!-- /.col -->
        <div class="col-xs-12">
            <div class="pull-right">
                {{ $users->appends(['key' => $key])->links() }}
            </div>
        </div>
    </div>
    <!-- /.row -->
@stop
